﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="find_by_role.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Staff.find_by_role" %>

<%@ Import Namespace="DataAccess" %>
<%@ Import Namespace="System.Linq" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <% 
        var id = int.Parse(Request.QueryString["id"]);
        var get_staff = new TblManagerController().FetchAll().ToList();
        if(id!=0)
            get_staff = new TblManagerController().FetchAll().Where(x => x.Role == id).ToList() ;
            
        var get_role = new TblManagerRoleController().FetchAll();
        %>
    <tr class="w3-teal">
        <th>Ảnh</th>
        <th>Tên đăng nhập</th>
        <th>Quyền</th>
        <th>Họ tên</th>
        <th>Ngày sinh</th>
        <th>Giới tính</th>
        <th>SĐT</th>
        <th>Email</th>
        <th>Kích hoạt</th>
        <th>Xóa</th>
    </tr>
    <%for (int i = 0; i < get_staff.Count;i++ )
      {
          if (get_staff[i].ManagerId == int.Parse(Session["admin_id"].ToString()))
              continue;
          %>
    <tr id="staff<%=get_staff[i].ManagerId%>" class="staff">
        <td class="w3-hide staff_id" ><%=get_staff[i].ManagerId%></td>
        <td class="staff-img">
            <img src="../Content/avatar/<%=get_staff[i].Avatar%>" class="w3-circle" /></td>
        <td><%=get_staff[i].ManagerName%></td>
        <td>
            <select class="change_role" style="padding: 1.1%">
                <%
          foreach (TblManagerRole role in get_role)
          { %>
                <%if (get_staff[i].Role == role.RoleId)
                  {%>
                <option value="<%=role.RoleId%>" selected="selected"><%=role.RoleName%></option>
                <%}
                  else
                  { %>
                <option value="<%=role.RoleId%>"><%=role.RoleName%></option>
                <%}
          } %>
            </select>
        </td>
        <td><%=get_staff[i].FullName%></td>
        <td><%=DateTime.Parse(get_staff[i].Birthday.ToString()).Day + "/" + DateTime.Parse(get_staff[i].Birthday.ToString()).Month + "/" + DateTime.Parse(get_staff[i].Birthday.ToString()).Year%></td>
        <td><%if (get_staff[i].Sex == true)
              { %>Nam<%}
              else
              {%>Nữ<%} %></td>
        <td><%=get_staff[i].Phone%></td>
        <td><%=get_staff[i].Email%></td>
        <%if (get_staff[i].Active == true)
          {%>
        <td class="option-btn">
            <i class="on1 fa fa-toggle-on w3-text-teal w3-animate-opacity"></i>
        </td>
        <%}
          else
          { %>
        <td class="option-btn">
            <i class="on1 fa fa-toggle-on w3-text-red w3-animate-opacity fa-rotate-180 off "></i>
        </td>
        <%} %>
        <td class="option-btn"><i class="del_staff fa fa-trash"></i></td>
    </tr>
    <%} %>
</body>
</html>
